package com.yueke.gemini.controller.impl;

import com.yueke.gemini.common.ApiResult;
import com.yueke.gemini.controller.IReferenceQueryController;
import com.yueke.gemini.entity.*;
import com.yueke.gemini.service.IReferenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * Created by admin on 2019/11/15.
 */
@Controller
public class ReferenceQueryController implements IReferenceQueryController {

    @Autowired
    private IReferenceService referenceService;

    @Override
    public ApiResult<List<KeyItem>> getKeyItems(RefQueryDTO query) {
        ApiResult<List<KeyItem>> apiResult = new ApiResult<List<KeyItem>>();
        List<KeyItem> keyItems = referenceService.getKeyItems(query);
        apiResult.setData(keyItems);
        return apiResult;
    }

    @Override
    public ApiResult<List<ModuleItem>> getModuleItemList() {
        ApiResult<List<ModuleItem>> apiResult = new ApiResult<List<ModuleItem>>();
        List<ModuleItem> itemList = referenceService.getModuleItemList();
        apiResult.setData(itemList);
        return apiResult;
    }

    @Override
    public ApiResult<List<RefModule>> getRefModuleList(@RequestBody RefQueryDTO query) {
        ApiResult<List<RefModule>> apiResult = new ApiResult<List<RefModule>>();
        List<RefModule> moduleList = referenceService.getRefModuleList(query);
        apiResult.setData(moduleList);
        return apiResult;
    }

    @Override
    public ApiResult<List<SubRefModule>> getRefSubModuleList(RefQueryDTO query) {
        ApiResult<List<SubRefModule>> apiResult = new ApiResult<List<SubRefModule>>();
        List<SubRefModule> moduleList = referenceService.getSubRefModuleList(query);
        apiResult.setData(moduleList);
        return apiResult;
    }
}
